/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Game;

import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;

/**
 * @author Vinicio Gomez
 */
public class Game {
    private int[][] elmapa;

    public Game(int[][] elmapa) {
        if (elmapa!=null){
            this.elmapa=elmapa;
        }
    }
    
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Image arena_pre;
    private Sprite piratas_f;
    public int piratas_fseq001Delay = 200;
    public int[] piratas_fseq001 = {1, 2, 3, 4, 5};
    private Image pirata_pre;
    private Image piratas;
    private TiledLayer Arena;
    private Image palmera_pre;
    private Image tesoro_pre;
    private Image palmera_t;
    private TiledLayer Tesoro_f;
    private Image tesoro_t;
    private TiledLayer Palmera;
//</editor-fold>//GEN-END:|fields|0|
    
//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
//</editor-fold>//GEN-END:|methods|0|

    public Image getArena_pre() throws java.io.IOException {//GEN-BEGIN:|1-getter|0|1-preInit
        if (arena_pre == null) {//GEN-END:|1-getter|0|1-preInit
            // write pre-init user code here
            arena_pre = Image.createImage("/Dibujos/arena_pre.png");//GEN-BEGIN:|1-getter|1|1-postInit
        }//GEN-END:|1-getter|1|1-postInit
        // write post-init user code here
        return this.arena_pre;//GEN-BEGIN:|1-getter|2|
    }//GEN-END:|1-getter|2|

    public Image getPirata_pre() throws java.io.IOException {//GEN-BEGIN:|4-getter|0|4-preInit
        if (pirata_pre == null) {//GEN-END:|4-getter|0|4-preInit
            // write pre-init user code here
            pirata_pre = Image.createImage("/Dibujos/piratas.png");//GEN-BEGIN:|4-getter|1|4-postInit
        }//GEN-END:|4-getter|1|4-postInit
        // write post-init user code here
        return this.pirata_pre;//GEN-BEGIN:|4-getter|2|
    }//GEN-END:|4-getter|2|



    public TiledLayer getArena() throws java.io.IOException {//GEN-BEGIN:|7-getter|0|7-preInit
        if (Arena == null) {//GEN-END:|7-getter|0|7-preInit
            // write pre-init user code here
            Arena = new TiledLayer(20, 20, getArena_pre(), 46, 46);//GEN-BEGIN:|7-getter|1|7-midInit
            int[][] tiles = {
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
            };//GEN-END:|7-getter|1|7-midInit
            // write mid-init user code here
            for (int row = 0; row < 20; row++) {//GEN-BEGIN:|7-getter|2|7-postInit
                for (int col = 0; col < 20; col++) {
                    Arena.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|7-getter|2|7-postInit
        // write post-init user code here
        return Arena;//GEN-BEGIN:|7-getter|3|
    }//GEN-END:|7-getter|3|

    public Image getPalmera_pre() throws java.io.IOException {//GEN-BEGIN:|8-getter|0|8-preInit
        if (palmera_pre == null) {//GEN-END:|8-getter|0|8-preInit
            // write pre-init user code here
            palmera_pre = Image.createImage("/Dibujos/palmera_t.png");//GEN-BEGIN:|8-getter|1|8-postInit
        }//GEN-END:|8-getter|1|8-postInit
        // write post-init user code here
        return this.palmera_pre;//GEN-BEGIN:|8-getter|2|
    }//GEN-END:|8-getter|2|



    public Image getTesoro_pre() throws java.io.IOException {//GEN-BEGIN:|10-getter|0|10-preInit
        if (tesoro_pre == null) {//GEN-END:|10-getter|0|10-preInit
            // write pre-init user code here
            tesoro_pre = Image.createImage("/Dibujos/tesoro_t.png");//GEN-BEGIN:|10-getter|1|10-postInit
        }//GEN-END:|10-getter|1|10-postInit
        // write post-init user code here
        return this.tesoro_pre;//GEN-BEGIN:|10-getter|2|
    }//GEN-END:|10-getter|2|



    public void updateLayerManagerForMapa1(LayerManager lm) throws java.io.IOException {//GEN-LINE:|12-updateLayerManager|0|12-preUpdate
        // write pre-update user code here
        getPiratas_f().setPosition(59, 41);//GEN-BEGIN:|12-updateLayerManager|1|12-postUpdate
        getPiratas_f().setVisible(true);
        lm.append(getPiratas_f());
        getPalmera().setPosition(12, 69);
        getPalmera().setVisible(true);
        lm.append(getPalmera());
        getTesoro_f().setPosition(17, 83);
        getTesoro_f().setVisible(true);
        lm.append(getTesoro_f());
        getArena().setPosition(0, 0);
        getArena().setVisible(true);
        lm.append(getArena());//GEN-END:|12-updateLayerManager|1|12-postUpdate
        // write post-update user code here
    }//GEN-LINE:|12-updateLayerManager|2|

    public Image getPalmera_t() throws java.io.IOException {//GEN-BEGIN:|51-getter|0|51-preInit
        if (palmera_t == null) {//GEN-END:|51-getter|0|51-preInit
            // write pre-init user code here
            palmera_t = Image.createImage("/Dibujos/palmera_t.png");//GEN-BEGIN:|51-getter|1|51-postInit
        }//GEN-END:|51-getter|1|51-postInit
        // write post-init user code here
        return this.palmera_t;//GEN-BEGIN:|51-getter|2|
    }//GEN-END:|51-getter|2|

    public TiledLayer getPalmera() throws java.io.IOException {//GEN-BEGIN:|52-getter|0|52-preInit
        if (Palmera == null) {//GEN-END:|52-getter|0|52-preInit
            // write pre-init user code here
            Palmera = new TiledLayer(20, 20, getPalmera_t(), 41, 41);//GEN-BEGIN:|52-getter|1|52-midInit
            int[][] tiles = {
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
                {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0},
                {0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0}
            };//GEN-END:|52-getter|1|52-midInit
            // write mid-init user code here
            if (this.elmapa!=null){
                tiles=this.elmapa;
            }
            for (int row = 0; row < 20; row++) {//GEN-BEGIN:|52-getter|2|52-postInit
                for (int col = 0; col < 20; col++) {
                    Palmera.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|52-getter|2|52-postInit
        // write post-init user code here
        return Palmera;//GEN-BEGIN:|52-getter|3|
    }//GEN-END:|52-getter|3|

    public TiledLayer getPalmera(int [][] tiles) throws java.io.IOException {                                   
        if (Palmera == null) {                                 
            // write pre-init user code here
            Palmera = new TiledLayer(20, 20, getPalmera_t(), 41, 41);                                   
                                
            // write mid-init user code here
            for (int row = 0; row < 20; row++) {                                    
                for (int col = 0; col < 20; col++) {
                    Palmera.setCell(col, row, tiles[row][col]);
                }
            }
        }                                  
        // write post-init user code here
        return Palmera;                         
    }  
    
    
    public Image getTesoro_t() throws java.io.IOException {//GEN-BEGIN:|53-getter|0|53-preInit
        if (tesoro_t == null) {//GEN-END:|53-getter|0|53-preInit
            // write pre-init user code here
            tesoro_t = Image.createImage("/Dibujos/tesoro_t.png");//GEN-BEGIN:|53-getter|1|53-postInit
        }//GEN-END:|53-getter|1|53-postInit
        // write post-init user code here
        return this.tesoro_t;//GEN-BEGIN:|53-getter|2|
    }//GEN-END:|53-getter|2|

    public TiledLayer getTesoro_f() throws java.io.IOException {//GEN-BEGIN:|54-getter|0|54-preInit
        if (Tesoro_f == null) {//GEN-END:|54-getter|0|54-preInit
            // write pre-init user code here
            Tesoro_f = new TiledLayer(20, 20, getTesoro_t(), 39, 41);//GEN-BEGIN:|54-getter|1|54-midInit
            int[][] tiles = {
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
            };//GEN-END:|54-getter|1|54-midInit
            // write mid-init user code here
            for (int row = 0; row < 20; row++) {//GEN-BEGIN:|54-getter|2|54-postInit
                for (int col = 0; col < 20; col++) {
                    Tesoro_f.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|54-getter|2|54-postInit
        // write post-init user code here
        return Tesoro_f;//GEN-BEGIN:|54-getter|3|
    }//GEN-END:|54-getter|3|

    public Image getPiratas() throws java.io.IOException {//GEN-BEGIN:|97-getter|0|97-preInit
        if (piratas == null) {//GEN-END:|97-getter|0|97-preInit
            // write pre-init user code here
            piratas = Image.createImage("/Dibujos/piratas.png");//GEN-BEGIN:|97-getter|1|97-postInit
        }//GEN-END:|97-getter|1|97-postInit
        // write post-init user code here
        return this.piratas;//GEN-BEGIN:|97-getter|2|
    }//GEN-END:|97-getter|2|

    public Sprite getPiratas_f() throws java.io.IOException {//GEN-BEGIN:|98-getter|0|98-preInit
        if (piratas_f == null) {//GEN-END:|98-getter|0|98-preInit
            // write pre-init user code here
            piratas_f = new Sprite(getPiratas(), 40, 40);//GEN-BEGIN:|98-getter|1|98-postInit
            piratas_f.setFrameSequence(piratas_fseq001);//GEN-END:|98-getter|1|98-postInit
            // write post-init user code here
        }//GEN-BEGIN:|98-getter|2|
        return piratas_f;
    }//GEN-END:|98-getter|2|


    
}
